/*
 * Teknei 2014 - All rights reserved
 */
package com.teknei.acabus.core.services;

import java.util.List;

import javax.ejb.Local;

import com.teknei.acabus.ServiceException;
import com.teknei.acabus.core.entities.NavigationChild;
import com.teknei.acabus.core.entities.NavigationParent;
import com.teknei.acabus.core.entities.Role;

/**
 * Interface for Navigation based on roles services
 * @author Jorge Amaro
 * @version 1.0
 * @since 1.0
 *
 */
@Local
public interface NavigationRolesService {

	/**
	 * Find roles related to the NavigationParent item
	 * @param element the NavigationParent
	 * @return the List<Role> with the items
	 * @throws ServiceException
	 */
	List<Role> findRolesAllowed(NavigationParent element)
			throws ServiceException;

	/**
	 * Finds the roles related to the NavigationChild item
	 * @param element the NavigationChild
	 * @return the List<Role> with the items
	 * @throws ServiceException
	 */
	List<Role> findRolesAllowed(NavigationChild element)
			throws ServiceException;

	/**
	 * Find all the roles in the database
	 * @return a List<Role> with all the items
	 * @throws ServiceException
	 */
	List<Role> findRoles() throws ServiceException;

	/**
	 * Finds the NavigationParent elements that a Role or a List<Role> can access
	 * @param roles the list with Roles
	 * @return a list with all the NavigationParent elements that those roles can access
	 * @throws ServiceException
	 */
	List<NavigationParent> findNavigationParentsByRoles(List<Role> roles)
			throws ServiceException;

	/**
	 * Finds the NavigationChild elements that a Role or a List of roles can access
	 * @param roles the list of roles
	 * @param parent the parent of the NavigationChild
	 * @return a list of NavigaionChild elements that those roles can access
	 * @throws ServiceException
	 */
	List<NavigationChild> findNavigationChildsByRoles(List<Role> roles,
			NavigationParent parent) throws ServiceException;

	/**
	 * Saves the role instance
	 * @param role
	 * @return the ID of the record 
	 * @throws ServiceException
	 */
	int saveRole(Role role) throws ServiceException;

	/**
	 * Deletes a role instance
	 * @param role
	 * @throws ServiceException
	 */
	void deleteRole(Role role) throws ServiceException;

	/**
	 * Updates a role instance
	 * @param role
	 * @throws ServiceException
	 */
	void updateRole(Role role) throws ServiceException;

	/**
	 * Saves a NavigationParent instance
	 * @param parent
	 * @return the ID of the record
	 * @throws ServiceException
	 */
	int saveNavigationParent(NavigationParent parent) throws ServiceException;

	/**
	 * Saves a NavigationChild instance
	 * @param child
	 * @return the ID of the record
	 * @throws ServiceException
	 */
	int saveNavigationChild(NavigationChild child) throws ServiceException;

	/**
	 * Updates a NavigationChild instance 
	 * @param child
	 * @throws ServiceException
	 */
	void updateNavigationChild(NavigationChild child) throws ServiceException;

	/**
	 * Updates a NavigationParent instance
	 * @param parent
	 * @throws ServiceException
	 */
	void updateNavigationParent(NavigationParent parent)
			throws ServiceException;

	/**
	 * Deletes a NavigationParent instance
	 * @param parent
	 * @throws ServiceException
	 */
	void deleteNavigationParent(NavigationParent parent)
			throws ServiceException;

	/**
	 * Deletes a NavigationChild instance
	 * @param child
	 * @throws ServiceException
	 */
	void deleteNavigationChild(NavigationChild child) throws ServiceException;

	/**
	 * Update the NavigationParent instance and its Role collection for updating the access to the module
	 * @param parent
	 * @throws ServiceException
	 */
	void updateNavigationParentWithRoles(NavigationParent parent)
			throws ServiceException;

	/**
	 * Updates the NavigationChild instance and its Role collection for updating the access to the module
	 * @param child
	 * @throws ServiceException
	 */
	void updateNavigationChildWithRoles(NavigationChild child)
			throws ServiceException;


}
